package com.caiyi.financial.nirvana.sms.controller;


import com.caiyi.financial.nirvana.sms.entity.SmsUserSign;
import com.caiyi.financial.nirvana.sms.querybean.SignQueryBean;
import com.caiyi.financial.nirvana.sms.service.SmsUserSignService;
import com.youyu.common.api.Result;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(description = "用户签名接口")
@CrossOrigin
@RestController
@RequestMapping("sms/admin/userSign")
public class UserSignController {

    @Autowired
    private SmsUserSignService smsUserSignService;


    @ApiOperation(value = "新增签名", notes = "新增签名")
    @PostMapping("/addSign")
    public Result addSign(@RequestBody @ApiParam(name = "smsSign", value = "客户签名", required = true) SmsUserSign smsSign) {
        return Result.ok(smsUserSignService.addSign(smsSign));
    }

    @ApiOperation(value = "查询客户签名", notes = "查询客户签名")
    @ApiImplicitParam(name = "bean", value = "实体参数", required = true, dataType = "SignQueryBean")
    @PostMapping("/getUserSign")
    public Result getUserSign(@RequestBody SignQueryBean bean) {
        return Result.ok(smsUserSignService.getSignByParams(bean));
    }

    @ApiOperation(value = "审核签名", notes = "审核签名")
    @PostMapping("/updateSign")
    public Result updateSign(@RequestBody @ApiParam(name = "smsSign", value = "客户签名", required = true) SmsUserSign smsSign) {
        return Result.ok(smsUserSignService.updateSign(smsSign.getId(), smsSign.getStatus(), smsSign.getReason()));
    }

    @ApiOperation(value = "设置默认签名", notes = "设置默认签名")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "签名id", required = true, dataType = "int", paramType = "query")
    })
    @PostMapping("/updateSignDefault")
    public Result updateSignDefault(Integer id) {
        return Result.ok(smsUserSignService.updateSignDefault(id));
    }

    @ApiOperation(value = "删除签名", notes = "删除签名")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "签名id", dataType = "int", paramType = "query", required = true)})
    @PostMapping("/deleteSign")
    public Result deleteSign(Integer id) {
        return Result.ok(smsUserSignService.deleteSmsSign(id));
    }

}
